//
//  ZHHomeViewCell.swift
//  ZHWeibo
//
//  Created by user on 15/12/9.
//  Copyright © 2015年 heima. All rights reserved.
//

import UIKit

class ZHHomeViewCell: UITableViewCell {
    //需要有一个模型,每一个微博数据的模型
    var cellViewModel: ZHStatusUserViewModel? {
        didSet{
            frendInfoView.statusUserViewModel = cellViewModel
            toolBarView.statusUserViewModel = cellViewModel
            reportContentView.statusUserViewModel = cellViewModel
        }
    }
    //构造方法
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setUpUI()
    }
    
    
    private func setUpUI() {
        contentView.addSubview(frendInfoView)
        contentView.addSubview(toolBarView)
        contentView.addSubview(reportContentView)
        //约束
        frendInfoView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentView)
            make.leading.equalTo(contentView)
            make.trailing.equalTo(contentView)
        }
        //约束
        reportContentView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(frendInfoView.snp_bottom)
            make.leading.equalTo(contentView)
            make.trailing.equalTo(contentView)
            
        }
        //约束
        toolBarView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(reportContentView.snp_bottom)
            make.leading.equalTo(contentView)
            make.trailing.equalTo(contentView)
        }
        
        //重要的约束----contentView约束,一个不能少
        contentView.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(toolBarView)
            make.bottom.top.equalTo(self)
            make.leading.equalTo(self)
            make.trailing.equalTo(self)
        }
    }
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //去掉cell的高亮状态
    override func setHighlighted(highlighted: Bool, animated: Bool) {
    }
    override func setSelected(selected: Bool, animated: Bool) {
    }
    //控件懒加载----这里必须指定类型-----为什么这里使用的这种创建方式,会自动转换成对frame的创建方式
    private lazy var frendInfoView: ZHFrendInfoView = ZHFrendInfoView()
    private lazy var reportContentView:ZHReportContentView = ZHReportContentView()
    private lazy var toolBarView: ZHToolBarView = ZHToolBarView()

}
